import urllib.request

# 请求地址
url = ("https://dianying.taobao.com/cityAction.json?activityId&_ksTS=1712926416542_104&"
       "jsoncallback=jsonp105&action=cityAction&n_s=new&event_submit_doGetAllRegion=true")

# UA 信息
headers = {
        'Accept':'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01',
        # 'Accept-Encoding':'gzip, deflate, br, zstd',
        'Accept-Language':'zh-CN,zh;q=0.9',
        'Bx-V':'2.5.11',
        'Cookie':'miid=111418621189933979; cna=XV89HZoyfSECAWVY9vZopwBt; t=57b3106835b0b18f9c4b0ae1be3ae135; thw=cn; 3PcFlag=1712494868512; lgc=%5Cu5C0F%5Cu7C73%5Cu52A0%5Cu8001%5Cu7C73; dnk=%5Cu5C0F%5Cu7C73%5Cu52A0%5Cu8001%5Cu7C73; tracknick=%5Cu5C0F%5Cu7C73%5Cu52A0%5Cu8001%5Cu7C73; sgcookie=E1000tQyLweX2oXz61n771RcSaP2ESzyaPMUz81GPWf4jyaSmraoHXZl5wbaVhXXa303WpL3q5wPR7c0aJehuW%2B2wC8maQ0Q4HIX2yvSaLVq577w6LNcguT%2BysW1ihduCxai; havana_lgc2_0=eyJoaWQiOjI5OTMzNjMxNzcsInNnIjoiZDQ0ZTdmZTJiZDkxZWVjNTNlNGQ0MGNmNWZhMDE0NzkiLCJzaXRlIjowLCJ0b2tlbiI6IjF4R252WElXRlRGNXhaazhsdDNXZkJ3In0; _hvn_lgc_=0; havana_lgc_exp=1711680939302; wk_cookie2=189cc1bfccba576bda043370f1c597d5; wk_unb=UUGrdT2%2B0acd0g%3D%3D; uc3=vt3=F8dD3e5p%2Bp8IdlQ7034%3D&lg2=UIHiLt3xD8xYTw%3D%3D&id2=UUGrdT2%2B0acd0g%3D%3D&nk2=symxAvNh0GZG5Q%3D%3D; uc4=id4=0%40U2OcRZ06zPecBcY73u7jb0EqN1cz&nk4=0%40sVYRYwJHd701ESKWZGRysE4M1ybK; _cc_=UtASsssmfA%3D%3D; mt=ci=2_1; cookie2=1cb9c38bed55701eb5d708bc5608441a; v=0; _tb_token_=53e43e7e73e36; isg=BGhow3GamhJveLUu8a-Fmdk4OVZ6kcybVj1I2CKYKuPWfQjnyqJFK7uzdRWNzYRz',
        'Referer':'https://dianying.taobao.com/',
        'Sec-Ch-Ua-Mobile':'?0',
        'Sec-Ch-Ua-Platform':'"Windows"',
        'Sec-Fetch-Dest':'empty',
        'Sec-Fetch-Mode':'cors',
        'Sec-Fetch-Site':'same-origin',
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
        'X-Requested-With':'XMLHttpRequest',
    }

request = urllib.request.Request(url, headers=headers)

response = urllib.request.urlopen(request)
content = response.read().decode('utf8')
content = content.split('(')[1].split(')')[0]
print(content)
with open('tpp.json', 'w', encoding='utf-8') as f:
    f.write(content)


